package com.will.willaicodemother.core.parser;

import com.will.willaicodemother.ai.enums.CodeGenTypeEnum;
import com.will.willaicodemother.ai.model.HtmlCodeResult;
import com.will.willaicodemother.ai.model.MultiFileCodeResult;

/**
 * @author will
 * @since 2025/8/8 16:56
 */
public class CodeParserExecutor {

    private static final CodeParser<HtmlCodeResult> HTML_CODE_PARSER = new HtmlCodeParser();
    private static final CodeParser<MultiFileCodeResult> MULTI_FILE_CODE_PARSER = new MultiFileCodeParser();

    /**
     * 执行代码解析
     *
     * @param codeContent 代码内容
     * @param codeGenType 代码生成类型
     * @return 解析结果
     */
    public static Object executeParser(String codeContent, CodeGenTypeEnum codeGenType) {
        return switch (codeGenType){
            case HTML -> HTML_CODE_PARSER.parseCode(codeContent);
            case MULTI_FILE -> MULTI_FILE_CODE_PARSER.parseCode(codeContent);
            default -> throw new IllegalArgumentException("不支持的代码生成类型：" + codeGenType);
        };
    }
}
